﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cms.Entity.Job;
using Frame.Lib.Utilities;
using Cms.BLL.Job;
using Frame.Lib.Core.Dict;
using Frame.Lib.Enums;

namespace Cms.Admin.Job
{
    public partial class Edit : PageEdit
    {
        private JobBO _job;
        private JobBO Job
        {
            get
            {
                if (_job == null)
                {
                    _job = new JobBO();
                }
                return _job;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebUtil.BindListControlWithEnum(Gender, typeof(JobGender));
                DictBO dict = new DictBO();
                dict.BindListControl(TypeCode, (int)DictItem.工作类型);
                if (PKID != null)
                {
                    DispInfo();
                }
                else
                {
                    PositionCount.Text = "1";
                }
            }
        }

        private void DispInfo()
        {
            JobInfo info = this.Job.GetInfo(this.PKID);

            EntityUtil.SetControl(pnlMain, info);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            JobInfo info = this.Job.GetInfo(this.PKID);

            EntityUtil.SetEntity(pnlMain, info);

            info.InputTime = DateTime.Now;
            info.Orders = this.Job.GetMaxOrder();
            info.TypeName = TypeCode.SelectedItem.Text;

            this.Job.Save(info);

            JSUtil.RefreshView();
        }
    }
}
